package cn.kgc.commons.interceptor;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

/**
 * <p>拦截器的配置类</p>
 */
@Configuration
@ConditionalOnClass(ResponseBodyAdvice.class)
public class InterceptorConfig  extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginUserNameInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/author/login","/author/register");
    }

}